<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2024/3/13
 * Time: 17:29
 */

namespace app\admin\validate;

use think\Validate;

class GoodsValidate extends Validate
{
    protected $rule = [
        'name'          => 'require',
        'img'           => 'require',
        'unit'          => 'require',
        'page'          => 'require',
        'goods_cate_id' => 'require|number',
        'spec_type'     => 'require|in:1,2',
        'specs'         => 'require',
        "limit"         => "require",
        "status"        => "require|in:1,2",
        'id'            => 'require',
    ];

    protected $message = [
        'name.require'          => '商品名称不能为空',
        'img.require'           => '商品图片不能为空',
        'unit.require'          => '商品单位不能为空',
        'goods_cate_id.require' => '商品分类不能为空',
        'goods_cate_id.number'  => '商品分类必须为数字',
        'spec_type.require'     => '商品规格类型不能为空',
        'spec_type.in'          => '商品规格类型值不正确',
        'specs.require'         => '商品规格不能为空',
        'page.require'          => '页码不能为空',
        'limit.require'         => '每页条数不能为空',
        'status.require'        => '状态不能为空',
        'status.in'             => '状态值不正确',
        'id.require'            => 'id不能为空',

    ];

    protected $scene = [
        'list'       => ['page', 'limit'],
        'add'        => ['img', 'name', 'unit', 'goods_cate_id', 'spec_type', 'specs'],
        "edit"       => ['id'],
        "editStatus" => ['id', "status"],
        "del"        => ['id'],
        "detail"     => ['id'],
        'addStaff'   => ['mobile', 'name', 'role_id'],
    ];
}